import { _decorator, Component, game, Label, Node } from 'cc';
import { GameEvent } from '../EventName';
import { HttpCom } from '../net/HttpCom';
const { ccclass, property } = _decorator;

@ccclass('RewardProp')
export class RewardProp extends Component {

    @property(Label)
    goldLab: Label = null;
    @property(Label)
    ticketLab: Label = null;

    @property(Label)
    tipInfoLab: Label = null;

    @property(Label)
    btnInfoLab: Label = null;


    @property(Node)
    rewardNode: Node = null;

    onCloseCallBack: Function = null;
    start() {

    }

    initView(gold: string, ticket: string,callBack: Function,tipInfo: string,btnInfo: string){
        HttpCom.getUserInfo();
        this.goldLab.string = gold;
        this.ticketLab.string = ticket;
        this.onCloseCallBack = callBack;
        this.tipInfoLab.string = tipInfo;
        this.btnInfoLab.string = btnInfo;

        if(ticket == "0"){
            this.rewardNode.children[0].active = false;
        }else{
            this.rewardNode.children[0].active = true;
        }
        if(gold == "0"){
            this.rewardNode.children[1].active = false;
        }else{
            this.rewardNode.children[1].active = true;
        }

        
    }

    onCloseBtnClick(){

        if(this.onCloseCallBack){
            this.onCloseCallBack();
            HttpCom.getUserInfo();
        }
        //game.emit(GameEvent.FIRE_CTRL,true);
        this.node.destroy();

    }

    update(deltaTime: number) {
        
    }
}


